import { IGlobalConfig, TScaleData } from "../type";

// 相片比例枚举
enum EPhotoScale {
  "原比例" = "",
  "1:1" = "1:1",
  "2:3" = "2:3",
  "3:4" = "3:4",
  "4:5" = "4:5",
  "5:6" = "5:6",
  "5:7" = "5:7",
  "7:10" = "7:10",
}

const photoMaxSize = 800; // 图片最大显示宽度/高度

// 默认全局配置
const defaultGlobalConfig: IGlobalConfig = {
  scale: EPhotoScale["3:4"],
  address: "", // 地址
  infoHeight: 80, // 照片信息高度
  infoPadding: 15, // 照片信息边距
  padding: 15, // 内边距
  maxPhotos: 20, // 最大操作图片张数
  dateFormat: "YYYY.MM.DD HH:mm:ss", // 日期格式
  exportImgFileType: "jpg", // 导出图片文件类型 todo
  isSign: true, // 是否添加水印
  customLogo: "", // 自定义logo
};

// 相纸比例宽高数据
const scaleData: TScaleData = (() => {
  const _scaleData: Partial<TScaleData> = {};
  Object.entries(EPhotoScale).forEach(([key, val]) => {
    // 没有值是原比例
    if (!val) {
      _scaleData[key as EPhotoScale] = {
        height: 0,
        width: 0,
      };
      return;
    }
    const [xScale, yScale] = val.split(":") as [string, string];
    _scaleData[key as EPhotoScale] = {
      height: photoMaxSize,
      width: (photoMaxSize / Number(yScale)) * Number(xScale),
    };
  });
  return _scaleData as TScaleData;
})();


export { defaultGlobalConfig, scaleData, EPhotoScale, photoMaxSize };
